package com.luo.chengrui.module.sa.dal.mysql.datapermission;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import com.luo.chengrui.module.sa.dal.dataobject.datapermission.DataPermissionConfigDO;
import com.luo.chengrui.module.sa.dal.dataobject.datapermission.DataPermissionConfigViewDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import com.luo.chengrui.module.sa.controller.admin.datapermission.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.formula.functions.T;

/**
 * 数据权限配置 Mapper
 *
 * @author 诚睿
 */
@Mapper
public interface DataPermissionConfigMapper extends BaseMapperX<DataPermissionConfigDO> {

    default PageResult<DataPermissionConfigDO> selectPage(DataPermissionConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DataPermissionConfigDO>()
                .likeIfPresent(DataPermissionConfigDO::getOrgFullId, reqVO.getOrgFullId())
                .likeIfPresent(DataPermissionConfigDO::getOrgFullName, reqVO.getOrgFullName())
                .eqIfPresent(DataPermissionConfigDO::getPermissionItemId, reqVO.getPermissionItemId())
                .eqIfPresent(DataPermissionConfigDO::getDataScope, reqVO.getDataScope())
                .eqIfPresent(DataPermissionConfigDO::getStatus, reqVO.getStatus())
                .eqIfPresent(DataPermissionConfigDO::getVersion, reqVO.getVersion())
                .betweenIfPresent(DataPermissionConfigDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DataPermissionConfigDO::getDataContent, reqVO.getDataContent())
                .orderByDesc(DataPermissionConfigDO::getId));
    }

    default List<DataPermissionConfigDO> selectList(DataPermissionConfigExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DataPermissionConfigDO>()
                .likeIfPresent(DataPermissionConfigDO::getOrgFullId, reqVO.getOrgFullId())
                .likeIfPresent(DataPermissionConfigDO::getOrgFullName, reqVO.getOrgFullName())
                .eqIfPresent(DataPermissionConfigDO::getPermissionItemId, reqVO.getPermissionItemId())
                .eqIfPresent(DataPermissionConfigDO::getDataScope, reqVO.getDataScope())
                .eqIfPresent(DataPermissionConfigDO::getStatus, reqVO.getStatus())
                .eqIfPresent(DataPermissionConfigDO::getVersion, reqVO.getVersion())
                .betweenIfPresent(DataPermissionConfigDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(DataPermissionConfigDO::getDataContent, reqVO.getDataContent())
                .orderByDesc(DataPermissionConfigDO::getId));
    }

    List<DataPermissionConfigDO> selectUserPermissionList(@Param("itemId")String id,@Param("userFullIds") List<String> personFullIds);

    IPage<DataPermissionConfigViewDO> selectPageCustomize(IPage<T> mpPage, @Param("params") DataPermissionConfigPageReqVO pageVO);
}
